package com.brush.brushcommon.common;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;


/**
 * 实体基础类
 *
 * @param <T>
 * @author cws
 */
@Data
public class BasicEntity<T extends Model> extends Model<BasicEntity<T>> {


    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private String id;



    @TableLogic
    @TableField(value = "is_deleted")
    @Schema(description = "删除标记（0：未删除，1：删除）")
    private Integer isDeleted;


    /**
     * 创建时间
     * 自动填充
     */
    @Schema(hidden = true)
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gmtCreate;

    /**
     * 修改时间
     * 自动填充
     */
    @Version
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gmtModified;

}

